package gmew.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.smartgwt.client.types.Side;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.menu.IMenuButton;
import com.smartgwt.client.widgets.menu.Menu;
import com.smartgwt.client.widgets.menu.MenuItem;
import com.smartgwt.client.widgets.menu.MenuItemSeparator;
import com.smartgwt.client.widgets.menu.events.ClickHandler;
import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
import com.smartgwt.client.widgets.tab.Tab;
import com.smartgwt.client.widgets.tab.TabSet;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Gmew implements EntryPoint {
	public static final GmewServiceAsync service = GWT.create(GmewService.class);
	private static TabSet sTabSet = new TabSet();
	
	public static TabSet getTabSet() {
		return sTabSet;
	}
	
	public void onModuleLoad()
	{
		Menu menuFile = new Menu();  
//		menuFile.setShowShadow(true);  
//		menuFile.setShadowDepth(10);  
		MenuItem newItem = new MenuItem("New");  
		MenuItem openItem = new MenuItem("Open");  
		MenuItem saveItem = new MenuItem("Save");  
		MenuItem saveAsItem = new MenuItem("Save As");  
		MenuItemSeparator separator = new MenuItemSeparator();
		menuFile.setItems(newItem, openItem, separator, saveItem, saveAsItem);  
		IMenuButton menuButtonFile = new IMenuButton("File", menuFile);
		menuButtonFile.setAutoFit(true);

		Menu menuAdmin = new Menu();  
//		menuFile.setShowShadow(true);  
//		menuFile.setShadowDepth(10);  
		MenuItem manageDbItem = new MenuItem("Manage Item Database");  
		manageDbItem.addClickHandler(new ClickHandler() {
			@Override
			public void onClick(MenuItemClickEvent event) {
				ItemDbPanel.activate();
			}
		});
		menuAdmin.setItems(manageDbItem);  
		IMenuButton menuButtonAdmin = new IMenuButton("Admin", menuAdmin);
		menuButtonAdmin.setAutoFit(true);
		
		HLayout menuBar = new HLayout();
		menuBar.setMembersMargin(10);
		menuBar.addMember(menuButtonFile);
		menuBar.addMember(menuButtonAdmin);
		menuBar.setAutoWidth();
		
		sTabSet.setWidth100();
		sTabSet.setHeight100();
		sTabSet.setTabBarPosition(Side.TOP);
		
		Label label = new Label("Gmew");
		Tab tab = new Tab("Gmew");
		tab.setPane(label);
		tab.setCanClose(true); 
		sTabSet.addTab(tab);
		
		VLayout vLayout = new VLayout();
		vLayout.setWidth100();
		vLayout.setHeight100();
		vLayout.setMembersMargin(10);
		vLayout.setMargin(10);
		vLayout.addMember(menuBar);
		vLayout.addMember(sTabSet);
		vLayout.draw();  
	}
}
